using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter23
{
	/// <summary>
	/// Example05: Electric Field Due to Two Charges
	/// A charge q_1 = 7 \mu C is located at the origin,
	/// and a second charge q_2 = -5.0 \mu C is located
	/// on the x axis, 0.3 m from the origin. Find the electric
	/// field at the point P, which has coordinates (0.0 m,0.4 m).
	/// E = 1.1 \times 10^5 i + 2.5 \times 10^5 j (N/C)	
	/// </summary>
	public class Example05
	{
		public Example05()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricCharge q1 = new L.ElectricCharge();
			q1.C = 7.0E-6;
			L.ElectricCharge q2 = new L.ElectricCharge();
			q2.C = -5.0E-6;
			L.ElectricCharge tq = new L.ElectricCharge();
			tq.C = 1.0;
				

			L.Position r1 = new L.Position();
			L.Position r2 = new L.Position();
			r2.X = 0.3;
			L.Position r3 = new L.Position();
			r3.Y = 0.4;

			L.ElectricForce F1 = new L.ElectricForce(q1,r1,tq,r3);
			L.ElectricForce F2 = new L.ElectricForce(q2,r2,tq,r3);
			
			L.Vector f = F1 + F2;

			result+=Convert.ToString(f.X)+" i + ";
			result+=Convert.ToString(f.Y)+" j\r\n";    
		}
	}
}
